<?php require('../globals.inc'); $mikron->Page->StartBody(); ?>
<?php require_once('menu.inc'); ?>
<h1>Поиск:</h1>

<?php

    $entities = $mikron->EntityManager->Items();
    $entities_for_search = Array();
    
    if(isset($_REQUEST['createindexes']))
    {
        foreach($entities as $entityname)
        {
            if(class_exists($entityname))
            {
                $entity = new $entityname();
                $fields_for_search = Array();
                foreach($entity->fields as $field)
                {
                    if($field['forsearch'])
                    {
                        $fields_for_search[] = $field['name'];
                    }
                }
                if(count($fields_for_search) > 0)
                {
                    $entities_for_search[$entityname] = $fields_for_search;
                }
            }
        }
        
        if(count($entities_for_search) == 0)
        {
            ?>Отсутствуют индексируемые сущности.<?php
        }
        else
        {
            foreach($entities_for_search as $entityname => $fields_for_search)
            {
                echo $entityname.", ";                
            }
        }
    }
    else
    {
        ?><a href="?createindexes">Переиндексировать сайт.</a><?php
    }

$mikron->Page->EndBody(); ?>